Remove __HYPERVISOR_sched_op_new in favour of a header file interface version number...
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Thu, 30 Mar 2006 16:50:44 +0000 (17:50 +0100)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Thu, 30 Mar 2006 16:50:44 +0000 (17:50 +0100)
Define interface version in Kconfig and define it through CPPFLAGS for
C and assembly file compilation.
Add HYPERVISOR_{yield,block,shutdown} to remove direct use of sched_op
from guest code.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
16 files changed:
linux-2.6-xen-sparse/arch/i386/Makefile
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
linux-2.6-xen-sparse/arch/ia64/Makefile
linux-2.6-xen-sparse/arch/x86_64/Makefile
linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c
linux-2.6-xen-sparse/drivers/xen/Kconfig
linux-2.6-xen-sparse/drivers/xen/core/reboot.c
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
linux-2.6-xen-sparse/include/asm-ia64/hypercall.h
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h
xen/include/public/xen-compat.h [new file with mode: 0644]
xen/include/public/xen.h

index d715e410e6a27d56acd4582accce30b630327445..54ee32ee57ab7f129eaedf0be7b0b1d839b1d1c8 100644 (file)
@@ -45,6 +45,11 @@ CFLAGS                               += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-op
 
 CFLAGS += $(cflags-y)
 
+cppflags-$(CONFIG_XEN) += \
+       -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+
+CPPFLAGS += $(cppflags-y)
+
 # Default subarch .c files
 mcore-y  := mach-default
 
index 47cde961a36fb9bf73b3e370dd059dcbca72e34b..02f2835f5672d89c666591a189c7e7fd298b4f57 100644 (file)
@@ -114,7 +114,7 @@ void xen_idle(void)
                smp_mb__after_clear_bit();
                stop_hz_timer();
                /* Blocking includes an implicit local_irq_enable(). */
-               HYPERVISOR_sched_op(SCHEDOP_block, 0);
+               HYPERVISOR_block();
                start_hz_timer();
                set_thread_flag(TIF_POLLING_NRFLAG);
        }
index 8a83da25e7a8f74effa8f059eb91f4e951d8bb8b..11d17a7a12799d88b6b090f45dd7150796dea4e1 100644 (file)
@@ -1877,7 +1877,7 @@ void __init setup_arch(char **cmdline_p)
 static int
 xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
-       HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+       HYPERVISOR_shutdown(SHUTDOWN_crash);
        /* we're never actually going to get here... */
        return NOTIFY_DONE;
 }
index 172b4cfd440bac6fd6400f361e6499eb8e7b5379..99487f443301c5e4e6b19270ddac2a50ebbe1009 100644 (file)
@@ -42,6 +42,12 @@ ifeq ($(call cc-version),0304)
 endif
 
 CFLAGS += $(cflags-y)
+
+cppflags-$(CONFIG_XEN) += \
+       -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+
+CPPFLAGS += $(cppflags-y)
+
 head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
 
 libs-y                         += arch/ia64/lib/
index 5d67f13b031d1e2ce426493714a58bee310d70ff..9164bf30a05697664af1f7da170cbc9665b18324 100644 (file)
@@ -31,6 +31,10 @@ cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
 cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
 CFLAGS += $(cflags-y)
 
+cppflags-$(CONFIG_XEN) += \
+       -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+CPPFLAGS += $(cppflags-y)
+
 CFLAGS += -m64
 CFLAGS += -mno-red-zone
 CFLAGS += -mcmodel=kernel
index d9830375721f266cde879e0db541ba7d86b4e9b2..7127fb57f367193fce7adbf07c1368a489e6d977 100644 (file)
@@ -131,7 +131,7 @@ void xen_idle(void)
                smp_mb__after_clear_bit();
                stop_hz_timer();
                /* Blocking includes an implicit local_irq_enable(). */
-               HYPERVISOR_sched_op(SCHEDOP_block, 0);
+               HYPERVISOR_block();
                start_hz_timer();
                set_thread_flag(TIF_POLLING_NRFLAG);
        }
index cfa9bbf17b93750c74e7c4117d2f3721f3cdcfde..30f8b405137e5ef80de4edaa8105176939d60223 100644 (file)
@@ -999,7 +999,7 @@ void __init setup_arch(char **cmdline_p)
 static int
 xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
-       HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+       HYPERVISOR_shutdown(SHUTDOWN_crash);
        /* we're never actually going to get here... */
        return NOTIFY_DONE;
 }
index f452b2f75d771d760f0118d0aa3a04a732fb415e..6518ff821aaa1518c54e18fd2589f91736cc7d86 100644 (file)
@@ -10,12 +10,11 @@ config XEN
        help
          This is the Linux Xen port.
 
-config NO_IDLE_HZ
-       bool
-       depends on XEN
-       default y
-
 if XEN
+config XEN_INTERFACE_VERSION
+       hex
+       default 0x00030101
+
 menu "XEN"
 
 config XEN_PRIVILEGED_GUEST
@@ -191,7 +190,6 @@ config XEN_DISABLE_SERIAL
 
 config XEN_SYSFS
        tristate "Export Xen attributes in sysfs"
-       depends on XEN
        depends on SYSFS
        default y
        help
@@ -207,4 +205,8 @@ config HAVE_ARCH_DEV_ALLOC_SKB
        bool
        default y
 
+config NO_IDLE_HZ
+       bool
+       default y
+
 endif
index 828d287f3e92dc3190e0ce438c02f62156ab1a11..990dc35cee645a81986926129abe8699c0a5c5c1 100644 (file)
@@ -42,7 +42,7 @@ void machine_emergency_restart(void)
 {
        /* We really want to get pending console data out before we die. */
        xencons_force_flush();
-       HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_reboot);
+       HYPERVISOR_shutdown(SHUTDOWN_reboot);
 }
 
 void machine_restart(char * __unused)
@@ -59,7 +59,7 @@ void machine_power_off(void)
 {
        /* We really want to get pending console data out before we die. */
        xencons_force_flush();
-       HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_poweroff);
+       HYPERVISOR_shutdown(SHUTDOWN_poweroff);
 }
 
 int reboot_thru_bios = 0;      /* for dmi_scan.c */
index a7832cad1a6e5122b052312ff71f702407392c13..20977d0b80783c77532c736571be8aed3c609691 100644 (file)
 #ifndef __HYPERCALL_H__
 #define __HYPERCALL_H__
 
-#include <xen/interface/xen.h>
-#include <xen/interface/sched.h>
-#include <xen/interface/nmi.h>
-#include <linux/errno.h>
+#ifndef __HYPERVISOR_H__
+# error "please don't include this file directly"
+#endif
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
@@ -167,35 +166,17 @@ HYPERVISOR_fpu_taskswitch(
 }
 
 static inline int
-HYPERVISOR_sched_op(
+HYPERVISOR_sched_op_compat(
        int cmd, unsigned long arg)
 {
-       return _hypercall2(int, sched_op, cmd, arg);
+       return _hypercall2(int, sched_op_compat, cmd, arg);
 }
 
 static inline int
-HYPERVISOR_sched_op_new(
+HYPERVISOR_sched_op(
        int cmd, void *arg)
 {
-       return _hypercall2(int, sched_op_new, cmd, arg);
-}
-
-static inline int
-HYPERVISOR_poll(
-       evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
-{
-       struct sched_poll sched_poll = {
-               .ports = ports,
-               .nr_ports = nr_ports,
-               .timeout = jiffies_to_st(timeout)
-       };
-
-       int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
-
-       if (rc == -ENOSYS)
-               rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
-
-       return rc;
+       return _hypercall2(int, sched_op, cmd, arg);
 }
 
 static inline long
@@ -327,8 +308,18 @@ static inline int
 HYPERVISOR_suspend(
        unsigned long srec)
 {
-       return _hypercall3(int, sched_op, SCHEDOP_shutdown,
-                          SHUTDOWN_suspend, srec);
+       struct sched_shutdown sched_shutdown = {
+               .reason = SHUTDOWN_suspend
+       };
+
+       int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+                            &sched_shutdown, srec);
+
+       if (rc == -ENOSYS)
+               rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
+                                SHUTDOWN_suspend, srec);
+
+       return rc;
 }
 
 static inline int
index 2bc97ae342a6ca493870159594200ec961245b3a..325a6c8a5b26b450d4a6894906743eb6919d87aa 100644 (file)
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
+#include <linux/errno.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/dom0_ops.h>
+#include <xen/interface/sched.h>
+#include <xen/interface/nmi.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 #if defined(__i386__)
@@ -115,6 +118,64 @@ u64 jiffies_to_st(unsigned long jiffies);
 
 #define xen_init()     (0)
 
+static inline int
+HYPERVISOR_yield(
+       void)
+{
+       int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_block(
+       void)
+{
+       int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_shutdown(
+       unsigned int reason)
+{
+       struct sched_shutdown sched_shutdown = {
+               .reason = reason
+       };
+
+       int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_poll(
+       evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
+{
+       struct sched_poll sched_poll = {
+               .ports = ports,
+               .nr_ports = nr_ports,
+               .timeout = jiffies_to_st(timeout)
+       };
+
+       int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+
+       return rc;
+}
+
 static inline void
 MULTI_update_va_mapping(
     multicall_entry_t *mcl, unsigned long va,
index b260c56e76af67b4d050dea1b3fc88acd98567f6..d255cf41cff3396b4c6de08741115b659c2aee9f 100644 (file)
 #ifndef __HYPERCALL_H__
 #define __HYPERCALL_H__
 
-#include <xen/interface/xen.h>
-#include <xen/interface/sched.h>
-#include <xen/interface/dom0_ops.h>
-#include <linux/errno.h>
+#ifndef __HYPERVISOR_H__
+# error "please don't include this file directly"
+#endif
 
 /* FIXME: temp place to hold these page related macros */
 #include <asm/page.h>
 })
 
 static inline int
-HYPERVISOR_sched_op(
+HYPERVISOR_sched_op_compat(
     int cmd, unsigned long arg)
 {
-       return _hypercall2(int, sched_op, cmd, arg);
+       return _hypercall2(int, sched_op_compat, cmd, arg);
 }
 
 static inline int
-HYPERVISOR_sched_op_new(
+HYPERVISOR_sched_op(
        int cmd, void *arg)
 {
-       return _hypercall2(int, sched_op_new, cmd, arg);
-}
-
-static inline int
-HYPERVISOR_poll(
-       evtchn_port_t *ports, unsigned int nr_ports, unsigned long timeout)
-{
-       struct sched_poll sched_poll = {
-               .ports = ports,
-               .nr_ports = nr_ports,
-               .timeout = jiffies_to_st(timeout)
-       };
-
-       int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
-
-       if (rc == -ENOSYS)
-               rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
-
-       return rc;
+       return _hypercall2(int, sched_op, cmd, arg);
 }
 
 static inline long
@@ -272,8 +253,18 @@ static inline int
 HYPERVISOR_suspend(
        unsigned long srec)
 {
-    return _hypercall3(int, sched_op, SCHEDOP_shutdown,
-                       SHUTDOWN_suspend, srec);
+       struct sched_shutdown sched_shutdown = {
+               .reason = SHUTDOWN_suspend
+       };
+
+       int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+                            &sched_shutdown, srec);
+
+       if (rc == -ENOSYS)
+               rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
+                                SHUTDOWN_suspend, srec);
+
+       return rc;
 }
 
 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
index 4a5f42441756f2a77d2b5728f63278bb7aaebc41..ecd51adcc0bc31c661112bf7243912df345e2960 100644 (file)
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
+#include <linux/errno.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/dom0_ops.h>
+#include <xen/interface/sched.h>
 #include <asm/ptrace.h>
 #include <asm/page.h>
 
@@ -54,6 +56,64 @@ int xen_init(void);
 
 #include <asm/hypercall.h>
 
+static inline int
+HYPERVISOR_yield(
+       void)
+{
+       int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_block(
+       void)
+{
+       int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_shutdown(
+       unsigned int reason)
+{
+       struct sched_shutdown sched_shutdown = {
+               .reason = reason
+       };
+
+       int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
+
+       return rc;
+}
+
+static inline int
+HYPERVISOR_poll(
+       evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
+{
+       struct sched_poll sched_poll = {
+               .ports = ports,
+               .nr_ports = nr_ports,
+               .timeout = jiffies_to_st(timeout)
+       };
+
+       int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
+
+       if (rc == -ENOSYS)
+               rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+
+       return rc;
+}
+
 // for drivers/xen/privcmd/privcmd.c
 #define direct_remap_pfn_range(a,b,c,d,e,f) remap_pfn_range(a,b,c,d,e)
 #define        pfn_to_mfn(x)   (x)
index 4071a1d6fd043285c7264e9fdb44fe18e82754b1..6b7411f4c5ceec134a37814c3371286e47dff31f 100644 (file)
 #ifndef __HYPERCALL_H__
 #define __HYPERCALL_H__
 
-#include <xen/interface/xen.h>
-#include <xen/interface/sched.h>
-#include <xen/interface/nmi.h>
-#include <linux/errno.h>
+#ifndef __HYPERVISOR_H__
+# error "please don't include this file directly"
+#endif
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
@@ -172,35 +171,17 @@ HYPERVISOR_fpu_taskswitch(
 }
 
 static inline int
-HYPERVISOR_sched_op(
+HYPERVISOR_sched_op_compat(
        int cmd, unsigned long arg)
 {
-       return _hypercall2(int, sched_op, cmd, arg);
+       return _hypercall2(int, sched_op_compat, cmd, arg);
 }
 
 static inline int
-HYPERVISOR_sched_op_new(
+HYPERVISOR_sched_op(
        int cmd, void *arg)
 {
-       return _hypercall2(int, sched_op_new, cmd, arg);
-}
-
-static inline int
-HYPERVISOR_poll(
-       evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
-{
-       struct sched_poll sched_poll = {
-               .ports = ports,
-               .nr_ports = nr_ports,
-               .timeout = jiffies_to_st(timeout)
-       };
-
-       int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
-
-       if (rc == -ENOSYS)
-               rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
-
-       return rc;
+       return _hypercall2(int, sched_op, cmd, arg);
 }
 
 static inline long
@@ -328,8 +309,18 @@ static inline int
 HYPERVISOR_suspend(
        unsigned long srec)
 {
-       return _hypercall3(int, sched_op, SCHEDOP_shutdown,
-                          SHUTDOWN_suspend, srec);
+       struct sched_shutdown sched_shutdown = {
+               .reason = SHUTDOWN_suspend
+       };
+
+       int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+                            &sched_shutdown, srec);
+
+       if (rc == -ENOSYS)
+               rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
+                                SHUTDOWN_suspend, srec);
+
+       return rc;
 }
 
 static inline int
diff --git a/xen/include/public/xen-compat.h b/xen/include/public/xen-compat.h
new file mode 100644 (file)
index 0000000..67af72b
--- /dev/null
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * xen-compat.h
+ * 
+ * Guest OS interface to Xen.  Compatibility layer.
+ * 
+ * Copyright (c) 2006, Christian Limpach
+ */
+
+#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
+#define __XEN_PUBLIC_XEN_COMPAT_H__
+
+#ifndef __XEN_INTERFACE_VERSION__
+#define __XEN_INTERFACE_VERSION__ 0x00000000
+#endif
+
+#if __XEN_INTERFACE_VERSION__ < 0x00030101
+#undef __HYPERVISOR_sched_op
+#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
+#endif
+
+#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
index 5d88c9c8afb463638336524d550a8545146f2592..2921a140cd06ba1612ce0ba91e34be8b7459a68a 100644 (file)
@@ -37,7 +37,7 @@
 #define __HYPERVISOR_stack_switch          3
 #define __HYPERVISOR_set_callbacks         4
 #define __HYPERVISOR_fpu_taskswitch        5
-#define __HYPERVISOR_sched_op              6
+#define __HYPERVISOR_sched_op_compat       6 /* compat as of 0x00030101 */
 #define __HYPERVISOR_dom0_op               7
 #define __HYPERVISOR_set_debugreg          8
 #define __HYPERVISOR_get_debugreg          9
@@ -59,7 +59,7 @@
 #define __HYPERVISOR_mmuext_op            26
 #define __HYPERVISOR_acm_op               27
 #define __HYPERVISOR_nmi_op               28
-#define __HYPERVISOR_sched_op_new         29
+#define __HYPERVISOR_sched_op             29
 
 /* 
  * VIRTUAL INTERRUPTS
@@ -436,6 +436,8 @@ typedef uint8_t xen_domain_handle_t[16];
 
 #endif /* !__ASSEMBLY__ */
 
+#include "xen-compat.h"
+
 #endif /* __XEN_PUBLIC_XEN_H__ */
 
 /*